const api = require("../../server/Api.js");
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    order: {},
    listHistory: {},
    id: "",
    userId: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      id: options.id,
      userId: app.globalData.userBean.consumerId
    })
    this.refreshData()
  },
  refreshData() {
    let that = this;
    api.refundDetail2(that.data.id).then(res => {
      for (let i = 0; i < res.listHistory.length; i++) {
        res.listHistory[i].remark = JSON.parse(res.listHistory[i].remark)
        if (res.listHistory[i].remark.avatar == "") {
          res.listHistory[i].remark.avatar = "../../images/logo.svg"
        }
      }
      that.setData({
        order: res.refundOrder,
        listHistory: res.listHistory
      })
    }).catch(msg => {
      console.log(msg)
    })
  },
  preview(e) {
    console.log(e)
    let that = this;
    tt.previewImage({
      current: e.currentTarget.dataset.url,
      urls: e.currentTarget.dataset.imgs
    })
  },
})